import { jQuery } from 'jquery';
!(function (e) {
  e(function () {
    function e() {}

    function t(t) {
      var n = new e();
      return (
        (n.then = function (e) {
          var n;
          try {
            return e && (n = e(t)), s(n === _ ? t : n);
          } catch (i) {
            return a(i);
          }
        }),
        w(n)
      );
    }

    function a(t) {
      var n = new e();
      return (
        (n.then = function (e, n) {
          var i;
          try {
            return n ? ((i = n(t)), s(i === _ ? t : i)) : a(t);
          } catch (o) {
            return a(o);
          }
        }),
        w(n)
      );
    }

    function n(e) {
      return r(e, function (e) {
        return a(e);
      });
    }

    function i() {
      function n(e, t, a) {
        return p(e, t, a);
      }

      function o(e) {
        d(t(e));
      }

      function r(e) {
        d(a(e));
      }

      function s(e) {
        f(e);
      }
      var c, l, u, h, p, f, d;
      return (
        (u = []),
        (h = []),
        (p = function (e, t, a) {
          var n = i();
          return (
            u.push(function (a) {
              a.then(e, t).then(n.resolve, n.reject, n.progress);
            }),
            a && h.push(a),
            n.promise
          );
        }),
        (f = function (e) {
          for (var t, a = 0; (t = h[a++]); ) t(e);
        }),
        (d = function (e) {
          var t,
            a = 0;
          for (
            p = e.then,
              d = f =
                function () {
                  throw new Error('already completed');
                },
              h = _;
            (t = u[a++]);

          )
            t(e);
          u = [];
        }),
        (c = {}),
        (l = new e()),
        (l.then = c.then = n),
        (c.promise = w(l)),
        (c.resolver = w({
          resolve: (c.resolve = o),
          reject: (c.reject = r),
          progress: (c.progress = s),
        })),
        c
      );
    }

    function o(e) {
      return e && 'function' == typeof e.then;
    }

    function r(e, t, a, n) {
      var i = s(e);
      return i.then(t, a, n);
    }

    function s(t) {
      var a, n;
      return (
        t instanceof e
          ? (a = t)
          : ((n = i()),
            o(t)
              ? (t.then(n.resolve, n.reject, n.progress), (a = n.promise))
              : (n.resolve(t), (a = n.promise))),
        a
      );
    }

    function c(e, t, a, n, o) {
      return (
        v(2, arguments),
        r(e, function (e) {
          function s(e) {
            m(e);
          }

          function c(e) {
            g(e);
          }

          function l(e) {
            v(e);
          }

          function u() {
            m = g = v = y;
          }
          var h, p, f, d, m, g, v, w, b;
          if (
            ((w = e.length >>> 0),
            (h = Math.max(0, Math.min(t, w))),
            (p = []),
            (d = i()),
            (f = r(d, a, n, o)),
            h)
          )
            for (
              m = function (e) {
                p.push(e), --h || (u(), d.resolve(p));
              },
                g = function (e) {
                  u(), d.reject(e);
                },
                v = d.progress,
                b = 0;
              w > b;
              ++b
            )
              b in e && r(e[b], s, c, l);
          else d.resolve(p);
          return f;
        })
      );
    }

    function l(e, t, a, n) {
      return (
        v(1, arguments),
        r(e, function (e) {
          return m(e, u, []);
        }).then(t, a, n)
      );
    }

    function u(e, t, a) {
      return (e[a] = t), e;
    }

    function h(e, t, a, n) {
      function i(e) {
        return t ? t(e[0]) : e[0];
      }
      return c(e, 1, i, a, n);
    }

    function p(e, t) {
      return r(e, function (e) {
        return f(e, t);
      });
    }

    function f(e, t) {
      var a, n, i;
      for (n = e.length >>> 0, a = new Array(n), i = 0; n > i; i++)
        i in e && (a[i] = r(e[i], t));
      return m(a, u, a);
    }

    function d(e, t, a) {
      var n = k.call(arguments, 1);
      return r(e, function (e) {
        return m.apply(_, [e].concat(n));
      });
    }

    function m(e, t, a) {
      var n, i;
      return (
        (n = e.length),
        (i = [
          function (e, a, i) {
            return r(e, function (e) {
              return r(a, function (a) {
                return t(e, a, i, n);
              });
            });
          },
        ]),
        arguments.length > 2 && i.push(a),
        b.apply(e, i)
      );
    }

    function g(e, t, n) {
      var i = arguments.length > 2;
      return r(
        e,
        function (e) {
          return i && (e = n), t.resolve(e), e;
        },
        function (e) {
          return t.reject(e), a(e);
        },
        t.progress
      );
    }

    function v(e, t) {
      for (var a, n = t.length; n > e; )
        if (((a = t[--n]), null != a && 'function' != typeof a))
          throw new Error('callback is not a function');
    }

    function y() {}
    var w, b, k, _;
    return (
      (r.defer = i),
      (r.reject = n),
      (r.isPromise = o),
      (r.all = l),
      (r.some = c),
      (r.any = h),
      (r.map = p),
      (r.reduce = d),
      (r.chain = g),
      (w =
        Object.freeze ||
        function (e) {
          return e;
        }),
      (e.prototype = w({
        always: function (e, t) {
          return this.then(e, e, t);
        },
        otherwise: function (e) {
          return this.then(_, e);
        },
      })),
      (k = [].slice),
      (b =
        [].reduce ||
        function (e) {
          var t, a, n, i, o;
          if (
            ((o = 0),
            (t = Object(this)),
            (i = t.length >>> 0),
            (a = arguments),
            a.length <= 1)
          )
            for (;;) {
              if (o in t) {
                n = t[o++];
                break;
              }
              if (++o >= i) throw new TypeError();
            }
          else n = a[1];
          for (; i > o; ++o) o in t && (n = e(n, t[o], o, t));
          return n;
        }),
      r
    );
  });
})(
  'function' == typeof define
    ? define
    : function (e) {
        'undefined' != typeof module
          ? (module.exports = e())
          : (jQuery.mapster_when = e());
      }
),
  (function ($) {
    ($.fn.mapster = function (e) {
      var t = $.mapster.impl;
      return $.isFunction(t[e])
        ? t[e].apply(this, Array.prototype.slice.call(arguments, 1))
        : 'object' != typeof e && e
        ? void $.error('Method ' + e + ' does not exist on jQuery.mapster')
        : t.bind.apply(this, arguments);
    }),
      ($.mapster = {
        version: '1.2.14-beta1',
        render_defaults: {
          isSelectable: !0,
          isDeselectable: !0,
          fade: !1,
          fadeDuration: 150,
          fill: !0,
          fillColor: '000000',
          fillColorMask: 'FFFFFF',
          fillOpacity: 0.7,
          highlight: !0,
          stroke: !1,
          strokeColor: 'ff0000',
          strokeOpacity: 1,
          strokeWidth: 1,
          includeKeys: '',
          altImage: null,
          altImageId: null,
          altImages: {},
        },
        defaults: {
          clickNavigate: !1,
          wrapClass: null,
          wrapCss: null,
          onGetList: null,
          sortList: !1,
          listenToList: !1,
          mapKey: '',
          mapValue: '',
          singleSelect: !1,
          listKey: 'value',
          listSelectedAttribute: 'selected',
          listSelectedClass: null,
          onClick: null,
          onMouseover: null,
          onMouseout: null,
          mouseoutDelay: 0,
          onStateChange: null,
          boundList: null,
          onConfigured: null,
          configTimeout: 3e4,
          noHrefIsMask: !0,
          scaleMap: !0,
          safeLoad: !1,
          areas: [],
        },
        shared_defaults: {
          render_highlight: {
            fade: !0,
          },
          render_select: {
            fade: !1,
          },
          staticState: null,
          selected: null,
        },
        area_defaults: {
          includeKeys: '',
          isMask: !1,
        },
        canvas_style: {
          position: 'absolute',
          left: 0,
          top: 0,
          padding: 0,
          border: 0,
        },
        hasCanvas: null,
        isTouch: null,
        map_cache: [],
        hooks: {},
        addHook: function (e, t) {
          this.hooks[e] = (this.hooks[e] || []).push(t);
        },
        callHooks: function (e, t) {
          $.each(this.hooks[e] || [], function (e, a) {
            a.apply(t);
          });
        },
        utils: {
          when: $.mapster_when,
          defer: $.mapster_when.defer,
          subclass: function (e, t) {
            var a = function () {
              var a = this,
                n = Array.prototype.slice.call(arguments, 0);
              (a.base = e.prototype),
                (a.base.init = function () {
                  e.prototype.constructor.apply(a, n);
                }),
                t.apply(a, n);
            };
            return (a.prototype = new e()), (a.prototype.constructor = a), a;
          },
          asArray: function (e) {
            return e.constructor === Array ? e : this.split(e);
          },
          split: function (e, t) {
            var a,
              n,
              i = e.split(',');
            for (a = 0; a < i.length; a++)
              (n = $.trim(i[a])),
                '' === n ? i.splice(a, 1) : (i[a] = t ? t(n) : n);
            return i;
          },
          updateProps: function (e, t) {
            var a,
              n = e || {},
              i = $.isEmptyObject(n) ? t : e;
            return (
              (a = []),
              $.each(i, function (e) {
                a.push(e);
              }),
              $.each(Array.prototype.slice.call(arguments, 1), function (e, t) {
                $.each(t || {}, function (e) {
                  if (!a || $.inArray(e, a) >= 0) {
                    var i = t[e];
                    $.isPlainObject(i)
                      ? (n[e] = $.extend(n[e] || {}, i))
                      : i && i.constructor === Array
                      ? (n[e] = i.slice(0))
                      : 'undefined' != typeof i && (n[e] = t[e]);
                  }
                });
              }),
              n
            );
          },
          isElement: function (e) {
            return 'object' == typeof HTMLElement
              ? e instanceof HTMLElement
              : e &&
                  'object' == typeof e &&
                  1 === e.nodeType &&
                  'string' == typeof e.nodeName;
          },
          indexOf: function (e, t) {
            for (var a = 0; a < e.length; a++) if (e[a] === t) return a;
            return -1;
          },
          indexOfProp: function (e, t, a) {
            var n = e.constructor === Array ? -1 : null;
            return (
              $.each(e, function (e, i) {
                return i && (t ? i[t] : i) === a ? ((n = e), !1) : void 0;
              }),
              n
            );
          },
          boolOrDefault: function (e, t) {
            return this.isBool(e) ? e : t || !1;
          },
          isBool: function (e) {
            return 'boolean' == typeof e;
          },
          isUndef: function (e) {
            return 'undefined' == typeof e;
          },
          ifFunction: function (e, t, a) {
            $.isFunction(e) && e.call(t, a);
          },
          size: function (e, t) {
            var a = $.mapster.utils;
            return {
              width: t ? e.width || e.naturalWidth : a.imgWidth(e, !0),
              height: t ? e.height || e.naturalHeight : a.imgHeight(e, !0),
              complete: function () {
                return !!this.height && !!this.width;
              },
            };
          },
          setOpacity: function (e, t) {
            $.mapster.hasCanvas()
              ? (e.style.opacity = t)
              : $(e).each(function (e, a) {
                  'undefined' != typeof a.opacity
                    ? (a.opacity = t)
                    : $(a).css('opacity', t);
                });
          },
          fader: (function () {
            var e = {},
              t = 0,
              a = function (n, i, o, r) {
                var s,
                  c,
                  l = r / 15,
                  u = $.mapster.utils;
                if ('number' == typeof n) {
                  if (((c = e[n]), !c)) return;
                } else
                  (s = u.indexOfProp(e, null, n)),
                    s && delete e[s],
                    (e[++t] = c = n),
                    (n = t);
                (o = o || 1),
                  (i = i + o / l > o - 0.01 ? o : i + o / l),
                  u.setOpacity(c, i),
                  o > i &&
                    setTimeout(function () {
                      a(n, i, o, r);
                    }, 15);
              };
            return a;
          })(),
        },
        getBoundList: function (e, t) {
          if (!e.boundList) return null;
          var a,
            n,
            i = $(),
            o = $.mapster.utils.split(t);
          return (
            e.boundList.each(function (t, r) {
              for (a = 0; a < o.length; a++)
                (n = o[a]),
                  $(r).is('[' + e.listKey + '="' + n + '"]') && (i = i.add(r));
            }),
            i
          );
        },
        setBoundListProperties: function (e, t, a) {
          t.each(function (t, n) {
            e.listSelectedClass &&
              (a
                ? $(n).addClass(e.listSelectedClass)
                : $(n).removeClass(e.listSelectedClass)),
              e.listSelectedAttribute && $(n).attr(e.listSelectedAttribute, a);
          });
        },
        getMapDataIndex: function (e) {
          var t, a;
          switch (e.tagName && e.tagName.toLowerCase()) {
            case 'area':
              (a = $(e).parent().attr('name')),
                (t = $("img[usemap='#" + a + "']")[0]);
              break;
            case 'img':
              t = e;
          }
          return t ? this.utils.indexOfProp(this.map_cache, 'image', t) : -1;
        },
        getMapData: function (e) {
          var t = this.getMapDataIndex(e.length ? e[0] : e);
          return t >= 0 ? (t >= 0 ? this.map_cache[t] : null) : void 0;
        },
        queueCommand: function (e, t, a, n) {
          return e && (!e.complete || e.currentAction)
            ? (e.commands.push({
                that: t,
                command: a,
                args: n,
              }),
              !0)
            : !1;
        },
        unload: function () {
          this.impl.unload(),
            (this.utils = null),
            (this.impl = null),
            ($.fn.mapster = null),
            ($.mapster = null),
            $('*').unbind();
        },
      });
    var m = $.mapster,
      u = m.utils,
      ap = Array.prototype;
    $.each(['width', 'height'], function (e, t) {
      var a = t.substr(0, 1).toUpperCase() + t.substr(1);
      u['img' + a] = function (e, n) {
        return (
          (n ? $(e)[t]() : 0) ||
          e[t] ||
          e['natural' + a] ||
          e['client' + a] ||
          e['offset' + a]
        );
      };
    }),
      (m.Method = function (e, t, a, n) {
        var i = this;
        (i.name = n.name),
          (i.output = e),
          (i.input = e),
          (i.first = n.first || !1),
          (i.args = n.args ? ap.slice.call(n.args, 0) : []),
          (i.key = n.key),
          (i.func_map = t),
          (i.func_area = a),
          (i.name = n.name),
          (i.allowAsync = n.allowAsync || !1);
      }),
      (m.Method.prototype = {
        constructor: m.Method,
        go: function () {
          var e,
            t,
            a,
            n,
            i,
            o = this.input,
            r = [],
            s = this;
          for (n = o.length, e = 0; n > e; e++)
            if ((t = $.mapster.getMapData(o[e]))) {
              if (!s.allowAsync && m.queueCommand(t, s.input, s.name, s.args)) {
                this.first && (i = '');
                continue;
              }
              if (
                ((a = t.getData('AREA' === o[e].nodeName ? o[e] : this.key)),
                a
                  ? $.inArray(a, r) < 0 && r.push(a)
                  : (i = this.func_map.apply(t, s.args)),
                this.first || 'undefined' != typeof i)
              )
                break;
            }
          return (
            $(r).each(function (e, t) {
              i = s.func_area.apply(t, s.args);
            }),
            'undefined' != typeof i ? i : this.output
          );
        },
      }),
      ($.mapster.impl = (function () {
        function hasVml() {
          var e = $('<div />').appendTo('body');
          e.html('<v:shape id="vml_flag1" adj="1" />');
          var t = e[0].firstChild;
          t.style.behavior = 'url(#default#VML)';
          var a = t ? 'object' == typeof t.adj : !0;
          return e.remove(), a;
        }

        function namespaces() {
          return 'object' == typeof document.namespaces
            ? document.namespaces
            : null;
        }

        function hasCanvas() {
          var e = namespaces();
          return e && e.g_vml_ ? !1 : $('<canvas />')[0].getContext ? !0 : !1;
        }

        function merge_areas(e, t) {
          var a,
            n,
            i = e.options.areas;
          t &&
            $.each(t, function (t, o) {
              o &&
                o.key &&
                ((n = u.indexOfProp(i, 'key', o.key)),
                n >= 0 ? $.extend(i[n], o) : i.push(o),
                (a = e.getDataForKey(o.key)),
                a && $.extend(a.options, o));
            });
        }

        function merge_options(e, t) {
          var a = u.updateProps({}, t);
          delete a.areas,
            u.updateProps(e.options, a),
            merge_areas(e, t.areas),
            u.updateProps(e.area_options, e.options);
        }
        var me = {},
          addMap = function (e) {
            return m.map_cache.push(e) - 1;
          },
          removeMap = function (e) {
            m.map_cache.splice(e.index, 1);
            for (var t = m.map_cache.length - 1; t >= this.index; t--)
              m.map_cache[t].index--;
          };
        return (
          (me.get = function (e) {
            var t = m.getMapData(this);
            if (!t || !t.complete)
              throw "Can't access data until binding complete.";
            return new m.Method(
              this,
              function () {
                return this.getSelected();
              },
              function () {
                return this.isSelected();
              },
              {
                name: 'get',
                args: arguments,
                key: e,
                first: !0,
                allowAsync: !0,
                defaultReturn: '',
              }
            ).go();
          }),
          (me.data = function (e) {
            return new m.Method(
              this,
              null,
              function () {
                return this;
              },
              {
                name: 'data',
                args: arguments,
                key: e,
              }
            ).go();
          }),
          (me.highlight = function (e) {
            return new m.Method(
              this,
              function () {
                if (e !== !1) {
                  var t = this.highlightId;
                  return t >= 0 ? this.data[t].key : null;
                }
                this.ensureNoHighlight();
              },
              function () {
                this.highlight();
              },
              {
                name: 'highlight',
                args: arguments,
                key: e,
                first: !0,
              }
            ).go();
          }),
          (me.keys = function (e, t) {
            function a(e) {
              var a,
                i = [];
              t
                ? ((a = e.areas()),
                  $.each(a, function (e, t) {
                    i = i.concat(t.keys);
                  }))
                : i.push(e.key),
                $.each(i, function (e, t) {
                  $.inArray(t, n) < 0 && n.push(t);
                });
            }
            var n = [],
              i = m.getMapData(this);
            if (!i || !i.complete)
              throw "Can't access data until binding complete.";
            return i && i.complete
              ? ('string' == typeof e
                  ? t
                    ? a(i.getDataForKey(e))
                    : (n = [i.getKeysForGroup(e)])
                  : ((t = e),
                    this.each(function (e, t) {
                      'AREA' === t.nodeName && a(i.getDataForArea(t));
                    })),
                n.join(','))
              : '';
          }),
          (me.select = function () {
            me.set.call(this, !0);
          }),
          (me.deselect = function () {
            me.set.call(this, !1);
          }),
          (me.set = function (e, t, a) {
            function n(t) {
              var a = e;
              if (t) {
                switch (e) {
                  case !0:
                    t.select(h);
                    break;
                  case !1:
                    t.deselect(!0);
                    break;
                  default:
                    a = t.toggle(h);
                }
                return a;
              }
            }

            function i(e) {
              e &&
                $.inArray(e, l) < 0 &&
                (l.push(e), (c += ('' === c ? '' : ',') + e.key));
            }

            function o(t) {
              $.each(l, function (e, a) {
                var i = n(a);
                t.options.boundList &&
                  m.setBoundListProperties(
                    t.options,
                    m.getBoundList(t.options, c),
                    i
                  );
              }),
                e || t.removeSelectionFinish();
            }
            var r,
              s,
              c,
              l,
              h = a;
            return (
              this.filter('img,area').each(function (a, n) {
                var p;
                (s = m.getMapData(n)),
                  s !== r && (r && o(r), (l = []), (c = '')),
                  s &&
                    ((p = ''),
                    'IMG' === n.nodeName.toUpperCase()
                      ? m.queueCommand(s, $(n), 'set', [e, t, h]) ||
                        (t instanceof Array
                          ? t.length && (p = t.join(','))
                          : (p = t),
                        p &&
                          $.each(u.split(p), function (e, t) {
                            i(s.getDataForKey(t.toString())), (r = s);
                          }))
                      : ((h = t),
                        m.queueCommand(s, $(n), 'set', [e, h]) ||
                          (i(s.getDataForArea(n)), (r = s))));
              }),
              s && o(s),
              this
            );
          }),
          (me.unbind = function (e) {
            return new m.Method(
              this,
              function () {
                this.clearEvents(), this.clearMapData(e), removeMap(this);
              },
              null,
              {
                name: 'unbind',
                args: arguments,
              }
            ).go();
          }),
          (me.rebind = function (e) {
            return new m.Method(
              this,
              function () {
                var t = this;
                (t.complete = !1),
                  t.configureOptions(e),
                  t.bindImages().then(function () {
                    t.buildDataset(!0), (t.complete = !0);
                  });
              },
              null,
              {
                name: 'rebind',
                args: arguments,
              }
            ).go();
          }),
          (me.get_options = function (e, t) {
            var a = u.isBool(e) ? e : t;
            return new m.Method(
              this,
              function () {
                var e = $.extend({}, this.options);
                return (
                  a &&
                    ((e.render_select = u.updateProps(
                      {},
                      m.render_defaults,
                      e,
                      e.render_select
                    )),
                    (e.render_highlight = u.updateProps(
                      {},
                      m.render_defaults,
                      e,
                      e.render_highlight
                    ))),
                  e
                );
              },
              function () {
                return a ? this.effectiveOptions() : this.options;
              },
              {
                name: 'get_options',
                args: arguments,
                first: !0,
                allowAsync: !0,
                key: e,
              }
            ).go();
          }),
          (me.set_options = function (e) {
            return new m.Method(
              this,
              function () {
                merge_options(this, e);
              },
              null,
              {
                name: 'set_options',
                args: arguments,
              }
            ).go();
          }),
          (me.unload = function () {
            var e;
            for (e = m.map_cache.length - 1; e >= 0; e--)
              m.map_cache[e] && me.unbind.call($(m.map_cache[e].image));
            me.graphics = null;
          }),
          (me.snapshot = function () {
            return new m.Method(
              this,
              function () {
                $.each(this.data, function (e, t) {
                  t.selected = !1;
                }),
                  (this.base_canvas = this.graphics.createVisibleCanvas(this)),
                  $(this.image).before(this.base_canvas);
              },
              null,
              {
                name: 'snapshot',
              }
            ).go();
          }),
          (me.state = function () {
            var e,
              t = null;
            return (
              $(this).each(function (a, n) {
                return 'IMG' === n.nodeName
                  ? ((e = m.getMapData(n)), e && (t = e.state()), !1)
                  : void 0;
              }),
              t
            );
          }),
          (me.bind = function (e) {
            return this.each(function (t, a) {
              var n, i, o, r;
              if (((n = $(a)), (r = m.getMapData(a)))) {
                if ((me.unbind.apply(n), !r.complete)) return n.bind(), !0;
                r = null;
              }
              return (
                (o = this.getAttribute('usemap')),
                (i = o && $('map[name="' + o.substr(1) + '"]')),
                n.is('img') && o && i.size() > 0
                  ? (n.css('border', 0),
                    void (
                      r ||
                      ((r = new m.MapData(this, e)),
                      (r.index = addMap(r)),
                      (r.map = i),
                      r.bindImages().then(function () {
                        r.initialize();
                      }))
                    ))
                  : !0
              );
            });
          }),
          (me.init = function (e) {
            var t, a;
            (m.hasCanvas = function () {
              return (
                u.isBool(m.hasCanvas.value) ||
                  (m.hasCanvas.value = u.isBool(e) ? e : hasCanvas()),
                m.hasCanvas.value
              );
            }),
              (m.hasVml = function () {
                if (!u.isBool(m.hasVml.value)) {
                  var e = namespaces();
                  e &&
                    !e.v &&
                    (e.add('v', 'urn:schemas-microsoft-com:vml'),
                    (t = document.createStyleSheet()),
                    (a = [
                      'shape',
                      'rect',
                      'oval',
                      'circ',
                      'fill',
                      'stroke',
                      'imagedata',
                      'group',
                      'textbox',
                    ]),
                    $.each(a, function (e, a) {
                      t.addRule(
                        'v\\:' + a,
                        'behavior: url(#default#VML); antialias:true'
                      );
                    })),
                    (m.hasVml.value = hasVml());
                }
                return m.hasVml.value;
              }),
              (m.isTouch = !!document.documentElement.ontouchstart),
              (u.indexOf = Array.prototype.indexOf || u.indexOf),
              $.extend(m.defaults, m.render_defaults, m.shared_defaults),
              $.extend(m.area_defaults, m.render_defaults, m.shared_defaults);
          }),
          (me.test = function (obj) {
            return eval(obj);
          }),
          me
        );
      })()),
      $.mapster.impl.init();
  })(jQuery),
  (function (e) {
    function t(t, a, n) {
      var i = t,
        o = i.map_data,
        r = n.isMask;
      e.each(a.areas(), function (e, t) {
        (n.isMask = r || (t.nohref && o.options.noHrefIsMask)),
          i.addShape(t, n);
      }),
        (n.isMask = r);
    }

    function a(e) {
      return Math.max(0, Math.min(parseInt(e, 16), 255));
    }

    function n(e, t) {
      return (
        'rgba(' +
        a(e.substr(0, 2)) +
        ',' +
        a(e.substr(2, 2)) +
        ',' +
        a(e.substr(4, 2)) +
        ',' +
        t +
        ')'
      );
    }

    function i() {}
    var o,
      r,
      s,
      c = e.mapster,
      l = c.utils;
    (c.Graphics = function (e) {
      var t = this;
      (t.active = !1),
        (t.canvas = null),
        (t.width = 0),
        (t.height = 0),
        (t.shapes = []),
        (t.masks = []),
        (t.map_data = e);
    }),
      (o = c.Graphics.prototype =
        {
          constructor: c.Graphics,
          begin: function (t, a) {
            var n = e(t);
            (this.elementName = a),
              (this.canvas = t),
              (this.width = n.width()),
              (this.height = n.height()),
              (this.shapes = []),
              (this.masks = []),
              (this.active = !0);
          },
          addShape: function (e, t) {
            var a = t.isMask ? this.masks : this.shapes;
            a.push({
              mapArea: e,
              options: t,
            });
          },
          createVisibleCanvas: function (t) {
            return e(this.createCanvasFor(t))
              .addClass('mapster_el')
              .css(c.canvas_style)[0];
          },
          addShapeGroup: function (a, n, i) {
            var o,
              r,
              s,
              u = this,
              h = this.map_data,
              p = a.effectiveRenderOptions(n);
            i && e.extend(p, i),
              'select' === n
                ? ((r = 'static_' + a.areaId.toString()), (s = h.base_canvas))
                : (s = h.overlay_canvas),
              u.begin(s, r),
              p.includeKeys &&
                ((o = l.split(p.includeKeys)),
                e.each(o, function (e, a) {
                  var i = h.getDataForKey(a.toString());
                  t(u, i, i.effectiveRenderOptions(n));
                })),
              t(u, a, p),
              u.render(),
              p.fade &&
                l.fader(
                  c.hasCanvas() ? s : e(s).find('._fill').not('.mapster_mask'),
                  0,
                  c.hasCanvas() ? 1 : p.fillOpacity,
                  p.fadeDuration
                );
          },
        }),
      (r = {
        renderShape: function (e, t, a) {
          var n,
            i = t.coords(null, a);
          switch (t.shape) {
            case 'rect':
              e.rect(i[0], i[1], i[2] - i[0], i[3] - i[1]);
              break;
            case 'poly':
              for (e.moveTo(i[0], i[1]), n = 2; n < t.length; n += 2)
                e.lineTo(i[n], i[n + 1]);
              e.lineTo(i[0], i[1]);
              break;
            case 'circ':
            case 'circle':
              e.arc(i[0], i[1], i[2], 0, 2 * Math.PI, !1);
          }
        },
        addAltImage: function (e, t, a, n) {
          e.beginPath(),
            this.renderShape(e, a),
            e.closePath(),
            e.clip(),
            (e.globalAlpha = n.altImageOpacity || n.fillOpacity),
            e.drawImage(
              t,
              0,
              0,
              a.owner.scaleInfo.width,
              a.owner.scaleInfo.height
            );
        },
        render: function () {
          var t,
            a,
            i = this,
            o = i.map_data,
            r = i.masks.length,
            s = i.createCanvasFor(o),
            c = s.getContext('2d'),
            l = i.canvas.getContext('2d');
          return (
            r &&
              ((t = i.createCanvasFor(o)),
              (a = t.getContext('2d')),
              a.clearRect(0, 0, t.width, t.height),
              e.each(i.masks, function (e, t) {
                a.save(),
                  a.beginPath(),
                  i.renderShape(a, t.mapArea),
                  a.closePath(),
                  a.clip(),
                  (a.lineWidth = 0),
                  (a.fillStyle = '#000'),
                  a.fill(),
                  a.restore();
              })),
            e.each(i.shapes, function (e, t) {
              c.save(),
                t.options.fill &&
                  (t.options.altImageId
                    ? i.addAltImage(
                        c,
                        o.images[t.options.altImageId],
                        t.mapArea,
                        t.options
                      )
                    : (c.beginPath(),
                      i.renderShape(c, t.mapArea),
                      c.closePath(),
                      (c.fillStyle = n(
                        t.options.fillColor,
                        t.options.fillOpacity
                      )),
                      c.fill())),
                c.restore();
            }),
            e.each(i.shapes.concat(i.masks), function (e, t) {
              var a = 1 === t.options.strokeWidth ? 0.5 : 0;
              t.options.stroke &&
                (c.save(),
                (c.strokeStyle = n(
                  t.options.strokeColor,
                  t.options.strokeOpacity
                )),
                (c.lineWidth = t.options.strokeWidth),
                c.beginPath(),
                i.renderShape(c, t.mapArea, a),
                c.closePath(),
                c.stroke(),
                c.restore());
            }),
            r
              ? ((a.globalCompositeOperation = 'source-out'),
                a.drawImage(s, 0, 0),
                l.drawImage(t, 0, 0))
              : l.drawImage(s, 0, 0),
            (i.active = !1),
            i.canvas
          );
        },
        createCanvasFor: function (t) {
          return e(
            '<canvas width="' +
              t.scaleInfo.width +
              '" height="' +
              t.scaleInfo.height +
              '"></canvas>'
          )[0];
        },
        clearHighlight: function () {
          var e = this.map_data.overlay_canvas;
          e.getContext('2d').clearRect(0, 0, e.width, e.height);
        },
        refreshSelections: function () {
          var t,
            a = this.map_data;
          (t = a.base_canvas),
            (a.base_canvas = this.createVisibleCanvas(a)),
            e(a.base_canvas).hide(),
            e(t).before(a.base_canvas),
            a.redrawSelections(),
            e(a.base_canvas).show(),
            e(t).remove();
        },
      }),
      (s = {
        renderShape: function (t, a, n) {
          var i,
            o,
            r,
            s,
            c,
            l,
            u,
            h = this,
            p = t.coords();
          switch (
            ((c = h.elementName ? 'name="' + h.elementName + '" ' : ''),
            (l = n ? 'class="' + n + '" ' : ''),
            (s =
              '<v:fill color="#' +
              a.fillColor +
              '" class="_fill" opacity="' +
              (a.fill ? a.fillOpacity : 0) +
              '" /><v:stroke class="_fill" opacity="' +
              a.strokeOpacity +
              '"/>'),
            (o = a.stroke
              ? ' strokeweight=' +
                a.strokeWidth +
                ' stroked="t" strokecolor="#' +
                a.strokeColor +
                '"'
              : ' stroked="f"'),
            (i = a.fill ? ' filled="t"' : ' filled="f"'),
            t.shape)
          ) {
            case 'rect':
              u =
                '<v:rect ' +
                l +
                c +
                i +
                o +
                ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' +
                p[0] +
                'px;top:' +
                p[1] +
                'px;width:' +
                (p[2] - p[0]) +
                'px;height:' +
                (p[3] - p[1]) +
                'px;">' +
                s +
                '</v:rect>';
              break;
            case 'poly':
              u =
                '<v:shape ' +
                l +
                c +
                i +
                o +
                ' coordorigin="0,0" coordsize="' +
                h.width +
                ',' +
                h.height +
                '" path="m ' +
                p[0] +
                ',' +
                p[1] +
                ' l ' +
                p.slice(2).join(',') +
                ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' +
                h.width +
                'px;height:' +
                h.height +
                'px;">' +
                s +
                '</v:shape>';
              break;
            case 'circ':
            case 'circle':
              u =
                '<v:oval ' +
                l +
                c +
                i +
                o +
                ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' +
                (p[0] - p[2]) +
                'px;top:' +
                (p[1] - p[2]) +
                'px;width:' +
                2 * p[2] +
                'px;height:' +
                2 * p[2] +
                'px;">' +
                s +
                '</v:oval>';
          }
          return (r = e(u)), e(h.canvas).append(r), r;
        },
        render: function () {
          var t,
            a = this;
          return (
            e.each(this.shapes, function (e, t) {
              a.renderShape(t.mapArea, t.options);
            }),
            this.masks.length &&
              e.each(this.masks, function (e, n) {
                (t = l.updateProps({}, n.options, {
                  fillOpacity: 1,
                  fillColor: n.options.fillColorMask,
                })),
                  a.renderShape(n.mapArea, t, 'mapster_mask');
              }),
            (this.active = !1),
            this.canvas
          );
        },
        createCanvasFor: function (t) {
          var a = t.scaleInfo.width,
            n = t.scaleInfo.height;
          return e(
            '<var width="' +
              a +
              '" height="' +
              n +
              '" style="zoom:1;overflow:hidden;display:block;width:' +
              a +
              'px;height:' +
              n +
              'px;"></var>'
          )[0];
        },
        clearHighlight: function () {
          e(this.map_data.overlay_canvas).children().remove();
        },
        removeSelections: function (t) {
          t >= 0
            ? e(this.map_data.base_canvas)
                .find('[name="static_' + t.toString() + '"]')
                .remove()
            : e(this.map_data.base_canvas).children().remove();
        },
      }),
      e.each(
        [
          'renderShape',
          'addAltImage',
          'render',
          'createCanvasFor',
          'clearHighlight',
          'removeSelections',
          'refreshSelections',
        ],
        function (e, t) {
          o[t] = (function (e) {
            return function () {
              return (
                (o[e] = (c.hasCanvas() ? r[e] : s[e]) || i),
                o[e].apply(this, arguments)
              );
            };
          })(t);
        }
      );
  })(jQuery),
  (function (e) {
    var t = e.mapster,
      a = t.utils,
      n = [];
    (t.MapImages = function (e) {
      (this.owner = e), this.clear();
    }),
      (t.MapImages.prototype = {
        constructor: t.MapImages,
        slice: function () {
          return n.slice.apply(this, arguments);
        },
        splice: function () {
          n.slice.apply(this.status, arguments);
          var e = n.slice.apply(this, arguments);
          return e;
        },
        complete: function () {
          return e.inArray(!1, this.status) < 0;
        },
        _add: function (e) {
          var t = n.push.call(this, e) - 1;
          return (this.status[t] = !1), t;
        },
        indexOf: function (e) {
          return a.indexOf(this, e);
        },
        clear: function () {
          var t = this;
          t.ids &&
            t.ids.length > 0 &&
            e.each(t.ids, function (e, a) {
              delete t[a];
            }),
            (t.ids = []),
            (t.length = 0),
            (t.status = []),
            t.splice(0);
        },
        add: function (t, a) {
          var n,
            i,
            o = this;
          if (t) {
            if ('string' == typeof t) {
              if (((i = t), (t = o[i]), 'object' == typeof t))
                return o.indexOf(t);
              (t = e('<img />').addClass('mapster_el').hide()),
                (n = o._add(t[0])),
                t
                  .bind('load', function (e) {
                    o.imageLoaded.call(o, e);
                  })
                  .bind('error', function (e) {
                    o.imageLoadError.call(o, e);
                  }),
                t.attr('src', i);
            } else n = o._add(e(t)[0]);
            if (a) {
              if (this[a])
                throw (
                  a +
                  ' is already used or is not available as an altImage alias.'
                );
              o.ids.push(a), (o[a] = o[n]);
            }
            return n;
          }
        },
        bind: function (e) {
          var t,
            n = this,
            i = n.owner.options.configTimeout / 200,
            o = function () {
              var e;
              for (e = n.length; e-- > 0 && n.isLoaded(e); );
              n.complete()
                ? n.resolve()
                : i-- > 0
                ? (n.imgTimeout = window.setTimeout(function () {
                    o.call(n, !0);
                  }, 50))
                : n.imageLoadError.call(n);
            };
          return (t = n.deferred = a.defer()), o(), t;
        },
        resolve: function () {
          var e = this,
            t = e.deferred;
          t && ((e.deferred = null), t.resolve());
        },
        imageLoaded: function (t) {
          var a = this,
            n = a.indexOf(t.target);
          n >= 0 &&
            ((a.status[n] = !0), e.inArray(!1, a.status) < 0 && a.resolve());
        },
        imageLoadError: function (e) {
          clearTimeout(this.imgTimeout), (this.triesLeft = 0);
          var t = e
            ? 'The image ' + e.target.src + ' failed to load.'
            : 'The images never seemed to finish loading. You may just need to increase the configTimeout if images could take a long time to load.';
          throw t;
        },
        isLoaded: function (e) {
          var t,
            n = this,
            i = n.status;
          return i[e]
            ? !0
            : ((t = n[e]),
              'undefined' != typeof t.complete
                ? (i[e] = t.complete)
                : (i[e] = !!a.imgWidth(t)),
              i[e]);
        },
      });
  })(jQuery),
  (function (e) {
    function t(t) {
      e.extend(t, {
        complete: !1,
        map: null,
        base_canvas: null,
        overlay_canvas: null,
        commands: [],
        data: [],
        mapAreas: [],
        _xref: {},
        highlightId: -1,
        currentAreaId: -1,
        _tooltip_events: [],
        scaleInfo: null,
        index: -1,
        activeAreaEvent: null,
      });
    }

    function a(e) {
      return [e, e.render_highlight, e.render_select];
    }

    function n(t) {
      var n = t.options,
        i = t.images;
      u.hasCanvas() &&
        (e.each(n.altImages || {}, function (e, t) {
          i.add(t, e);
        }),
        e.each([n].concat(n.areas), function (t, n) {
          e.each(a(n), function (e, t) {
            t && t.altImage && (t.altImageId = i.add(t.altImage));
          });
        })),
        (t.area_options = h.updateProps({}, u.area_defaults, n));
    }

    function i(e, t, a, n) {
      function o(t) {
        e.currentAreaId !== t && e.highlightId >= 0 && n.resolve();
      }
      return (
        (n = n || h.when.defer()),
        e.activeAreaEvent &&
          (window.clearTimeout(e.activeAreaEvent), (e.activeAreaEvent = 0)),
        0 > t
          ? n.reject()
          : a.owner.currentAction || t
          ? (e.activeAreaEvent = window.setTimeout(
              (function () {
                return function () {
                  i(e, 0, a, n);
                };
              })(a),
              t || 100
            ))
          : o(a.areaId),
        n
      );
    }

    function o(e) {
      u.hasCanvas() || this.blur(), e.preventDefault();
    }

    function r(t, a) {
      var n = t.getAllDataForArea(this),
        i = n.length ? n[0] : null;
      !i ||
        i.isNotRendered() ||
        i.owner.currentAction ||
        (t.currentAreaId !== i.areaId &&
          (t.highlightId !== i.areaId &&
            (t.clearEffects(),
            i.highlight(),
            t.options.showToolTip &&
              e.each(n, function (e, t) {
                t.effectiveOptions().toolTip && t.showToolTip();
              })),
          (t.currentAreaId = i.areaId),
          e.isFunction(t.options.onMouseover) &&
            t.options.onMouseover.call(this, {
              e: a,
              options: i.effectiveOptions(),
              key: i.key,
              selected: i.isSelected(),
            })));
    }

    function s(t, a) {
      var n,
        o = t.getDataForArea(this),
        r = t.options;
      t.currentAreaId < 0 ||
        !o ||
        ((n = t.getDataForArea(a.relatedTarget)),
        n !== o &&
          ((t.currentAreaId = -1),
          (o.area = null),
          i(t, r.mouseoutDelay, o).then(t.clearEffects),
          e.isFunction(r.onMouseout) &&
            r.onMouseout.call(this, {
              e: a,
              options: r,
              key: o.key,
              selected: o.isSelected(),
            })));
    }

    function c(t) {
      var a = t.options;
      t.ensureNoHighlight(),
        a.toolTipClose &&
          e.inArray('area-mouseout', a.toolTipClose) >= 0 &&
          t.activeToolTip &&
          t.clearToolTip();
    }

    function l(t, a) {
      function n(o) {
        var d, g;
        if (
          ((l = o.isSelectable() && (o.isDeselectable() || !o.isSelected())),
          (c = l ? !o.isSelected() : o.isSelected()),
          (s = u.getBoundList(m, o.key)),
          e.isFunction(m.onClick) &&
            ((p = m.onClick.call(f, {
              e: a,
              listTarget: s,
              key: o.key,
              selected: c,
            })),
            h.isBool(p)))
        ) {
          if (!p) return !1;
          if (((g = e(o.area).attr('href')), '#' !== g))
            return (window.location.href = g), !1;
        }
        l && (i = o.toggle()),
          m.boundList &&
            m.boundList.length > 0 &&
            u.setBoundListProperties(m, s, o.isSelected()),
          (d = o.effectiveOptions()),
          d.includeKeys &&
            ((r = h.split(d.includeKeys)),
            e.each(r, function (e, a) {
              var i = t.getDataForKey(a.toString());
              i.options.isMask || n(i);
            }));
      }
      var i,
        r,
        s,
        c,
        l,
        p,
        f = this,
        d = t.getDataForArea(this),
        m = t.options;
      return (
        o.call(this, a),
        m.clickNavigate && d.href
          ? void (window.location.href = d.href)
          : void (d && !d.owner.currentAction && ((m = t.options), n(d)))
      );
    }
    var u = e.mapster,
      h = u.utils;
    (u.MapData = function (e, a) {
      var n = this;
      (n.image = e),
        (n.images = new u.MapImages(n)),
        (n.graphics = new u.Graphics(n)),
        (n.imgCssText = e.style.cssText || null),
        t(n),
        n.configureOptions(a),
        (n.mouseover = function (e) {
          r.call(this, n, e);
        }),
        (n.mouseout = function (e) {
          s.call(this, n, e);
        }),
        (n.click = function (e) {
          l.call(this, n, e);
        }),
        (n.clearEffects = function (e) {
          c.call(this, n, e);
        });
    }),
      (u.MapData.prototype = {
        constructor: u.MapData,
        configureOptions: function (e) {
          this.options = h.updateProps({}, u.defaults, e);
        },
        bindImages: function () {
          var e = this,
            t = e.images;
          return (
            t.length > 2
              ? t.splice(2)
              : 0 === t.length && (t.add(e.image), t.add(e.image.src)),
            n(e),
            e.images.bind()
          );
        },
        isActive: function () {
          return !this.complete || this.currentAction;
        },
        state: function () {
          return {
            complete: this.complete,
            resizing: 'resizing' === this.currentAction,
            zoomed: this.zoomed,
            zoomedArea: this.zoomedArea,
            scaleInfo: this.scaleInfo,
          };
        },
        wrapId: function () {
          return 'mapster_wrap_' + this.index;
        },
        _idFromKey: function (e) {
          return 'string' == typeof e && this._xref.hasOwnProperty(e)
            ? this._xref[e]
            : -1;
        },
        getSelected: function () {
          var t = '';
          return (
            e.each(this.data, function (e, a) {
              a.isSelected() && (t += (t ? ',' : '') + this.key);
            }),
            t
          );
        },
        getAllDataForArea: function (t, a) {
          var n,
            i,
            o,
            r = this,
            s = e(t).filter('area').attr(r.options.mapKey);
          if (s)
            for (o = [], s = h.split(s), n = 0; n < (a || s.length); n++)
              (i = r.data[r._idFromKey(s[n])]),
                (i.area = t.length ? t[0] : t),
                o.push(i);
          return o;
        },
        getDataForArea: function (e) {
          var t = this.getAllDataForArea(e, 1);
          return t ? t[0] || null : null;
        },
        getDataForKey: function (e) {
          return this.data[this._idFromKey(e)];
        },
        getKeysForGroup: function (e) {
          var t = this.getDataForKey(e);
          return t
            ? t.isPrimary
              ? t.key
              : this.getPrimaryKeysForMapAreas(t.areas()).join(',')
            : '';
        },
        getPrimaryKeysForMapAreas: function (t) {
          var a = [];
          return (
            e.each(t, function (t, n) {
              e.inArray(n.keys[0], a) < 0 && a.push(n.keys[0]);
            }),
            a
          );
        },
        getData: function (e) {
          return 'string' == typeof e
            ? this.getDataForKey(e)
            : (e && e.mapster) || h.isElement(e)
            ? this.getDataForArea(e)
            : null;
        },
        ensureNoHighlight: function () {
          var e;
          this.highlightId >= 0 &&
            (this.graphics.clearHighlight(),
            (e = this.data[this.highlightId]),
            e.changeState('highlight', !1),
            this.setHighlightId(-1));
        },
        setHighlightId: function (e) {
          this.highlightId = e;
        },
        clearSelections: function () {
          e.each(this.data, function (e, t) {
            t.selected && t.deselect(!0);
          }),
            this.removeSelectionFinish();
        },
        setAreaOptions: function (e) {
          var t, a, n;
          for (e = e || [], t = e.length - 1; t >= 0; t--)
            (a = e[t]),
              a &&
                ((n = this.getDataForKey(a.key)),
                n &&
                  (h.updateProps(n.options, a),
                  h.isBool(a.selected) && (n.selected = a.selected)));
        },
        drawSelections: function (e) {
          var t,
            a = h.asArray(e);
          for (t = a.length - 1; t >= 0; t--) this.data[a[t]].drawSelection();
        },
        redrawSelections: function () {
          e.each(this.data, function (e, t) {
            t.isSelectedOrStatic() && t.drawSelection();
          });
        },
        initialize: function () {
          var t,
            a,
            n,
            i,
            o,
            r,
            s,
            c,
            l,
            p,
            f,
            d,
            m = this,
            g = m.options;
          if (!m.complete) {
            for (
              l = e(m.image),
                o = l.parent().attr('id'),
                o && o.length >= 12 && 'mapster_wrap' === o.substring(0, 12)
                  ? ((i = l.parent()), i.attr('id', m.wrapId()))
                  : ((i = e('<div id="' + m.wrapId() + '"></div>')),
                    g.wrapClass &&
                      (g.wrapClass === !0
                        ? i.addClass(l[0].className)
                        : i.addClass(g.wrapClass))),
                m.wrapper = i,
                m.scaleInfo = d =
                  h.scaleMap(m.images[0], m.images[1], g.scaleMap),
                m.base_canvas = a = m.graphics.createVisibleCanvas(m),
                m.overlay_canvas = n = m.graphics.createVisibleCanvas(m),
                t = e(m.images[1])
                  .addClass('mapster_el ' + m.images[0].className)
                  .attr({
                    id: null,
                    usemap: null,
                  }),
                c = h.size(m.images[0]),
                c.complete &&
                  t.css({
                    width: c.width,
                    height: c.height,
                  }),
                m.buildDataset(),
                r = {
                  display: 'block',
                  position: 'relative',
                  padding: 0,
                  width: d.width,
                  height: d.height,
                },
                g.wrapCss && e.extend(r, g.wrapCss),
                l.parent()[0] !== m.wrapper[0] && l.before(m.wrapper),
                i.css(r),
                e(m.images.slice(2)).hide(),
                s = 1;
              s < m.images.length;
              s++
            )
              i.append(m.images[s]);
            i.append(a).append(n).append(l.css(u.canvas_style)),
              h.setOpacity(m.images[0], 0),
              e(m.images[1]).show(),
              h.setOpacity(m.images[1], 1),
              g.isSelectable &&
                g.onGetList &&
                ((f = m.data.slice(0)),
                g.sortList &&
                  ((p =
                    'desc' === g.sortList
                      ? function (e, t) {
                          return e === t ? 0 : e > t ? -1 : 1;
                        }
                      : function (e, t) {
                          return e === t ? 0 : t > e ? -1 : 1;
                        }),
                  f.sort(function (e, t) {
                    return (e = e.value), (t = t.value), p(e, t);
                  })),
                (m.options.boundList = g.onGetList.call(m.image, f))),
              (m.complete = !0),
              m.processCommandQueue(),
              g.onConfigured &&
                'function' == typeof g.onConfigured &&
                g.onConfigured.call(l, !0);
          }
        },
        buildDataset: function (t) {
          function a(e, t) {
            var a = new u.AreaData(w, e, t);
            return (a.areaId = w._xref[e] = w.data.push(a) - 1), a.areaId;
          }
          var n,
            i,
            o,
            r,
            s,
            c,
            l,
            h,
            p,
            f,
            d,
            m,
            g,
            v,
            y,
            w = this,
            b = w.options;
          for (
            w._xref = {},
              w.data = [],
              t || (w.mapAreas = []),
              y = !b.mapKey,
              y && (b.mapKey = 'data-mapster-key'),
              n = u.hasVml()
                ? 'area'
                : y
                ? 'area[coords]'
                : 'area[' + b.mapKey + ']',
              i = e(w.map).find(n).unbind('.mapster'),
              d = 0;
            d < i.length;
            d++
          )
            if (((r = 0), (c = i[d]), (s = e(c)), c.coords)) {
              for (
                y
                  ? ((l = String(d)), s.attr('data-mapster-key', l))
                  : (l = c.getAttribute(b.mapKey)),
                  t
                    ? ((h = w.mapAreas[s.data('mapster') - 1]), h.configure(l))
                    : ((h = new u.MapArea(w, c, l)), w.mapAreas.push(h)),
                  f = h.keys,
                  o = f.length - 1;
                o >= 0;
                o--
              )
                (p = f[o]),
                  b.mapValue && (m = s.attr(b.mapValue)),
                  y
                    ? ((r = a(w.data.length, m)),
                      (g = w.data[r]),
                      (g.key = p = r.toString()))
                    : ((r = w._xref[p]),
                      r >= 0
                        ? ((g = w.data[r]),
                          m && !w.data[r].value && (g.value = m))
                        : ((r = a(p, m)),
                          (g = w.data[r]),
                          (g.isPrimary = 0 === o))),
                  h.areaDataXref.push(r),
                  g.areasXref.push(d);
              (v = s.attr('href')),
                v && '#' !== v && !g.href && (g.href = v),
                h.nohref ||
                  s
                    .bind('click.mapster', w.click)
                    .bind('mouseover.mapster, touchstart.mapster', w.mouseover)
                    .bind('mouseout.mapster, touchend.mapster', w.mouseout)
                    .bind('mousedown.mapster', w.mousedown),
                s.data('mapster', d + 1);
            }
          w.setAreaOptions(b.areas), w.redrawSelections();
        },
        processCommandQueue: function () {
          for (var e, t = this; !t.currentAction && t.commands.length; )
            (e = t.commands[0]),
              t.commands.splice(0, 1),
              u.impl[e.command].apply(e.that, e.args);
        },
        clearEvents: function () {
          e(this.map).find('area').unbind('.mapster'),
            e(this.images).unbind('.mapster');
        },
        _clearCanvases: function (t) {
          t || e(this.base_canvas).remove(), e(this.overlay_canvas).remove();
        },
        clearMapData: function (t) {
          var a = this;
          this._clearCanvases(t),
            e.each(this.data, function (e, t) {
              t.reset();
            }),
            (this.data = null),
            t ||
              ((this.image.style.cssText = this.imgCssText),
              e(this.wrapper).before(this.image).remove()),
            a.images.clear(),
            (this.image = null),
            h.ifFunction(this.clearTooltip, this);
        },
        removeSelectionFinish: function () {
          var e = this.graphics;
          e.refreshSelections(), e.clearHighlight();
        },
      });
  })(jQuery),
  (function (e) {
    function t(t) {
      var a = this,
        n = a.owner;
      n.options.singleSelect && n.clearSelections(),
        a.isSelected() ||
          (t &&
            (a.optsCache = e.extend(a.effectiveRenderOptions('select'), t, {
              altImageId: n.images.add(t.altImage),
            })),
          a.drawSelection(),
          (a.selected = !0),
          a.changeState('select', !0)),
        n.options.singleSelect && n.graphics.refreshSelections();
    }

    function a(e) {
      var t = this;
      (t.selected = !1),
        t.changeState('select', !1),
        (t.optsCache = null),
        t.owner.graphics.removeSelections(t.areaId),
        e || t.owner.removeSelectionFinish();
    }

    function n(e) {
      var t = this;
      return t.isSelected() ? t.deselect() : t.select(e), t.isSelected();
    }
    var i = e.mapster,
      o = i.utils;
    (i.AreaData = function (t, a, n) {
      e.extend(this, {
        owner: t,
        key: a || '',
        isPrimary: !0,
        areaId: -1,
        href: '',
        value: n || '',
        options: {},
        selected: null,
        areasXref: [],
        area: null,
        optsCache: null,
      });
    }),
      (i.AreaData.prototype = {
        constuctor: i.AreaData,
        select: t,
        deselect: a,
        toggle: n,
        areas: function () {
          var e,
            t = [];
          for (e = 0; e < this.areasXref.length; e++)
            t.push(this.owner.mapAreas[this.areasXref[e]]);
          return t;
        },
        coords: function (t) {
          var a = [];
          return (
            e.each(this.areas(), function (e, n) {
              a = a.concat(n.coords(t));
            }),
            a
          );
        },
        reset: function () {
          e.each(this.areas(), function (e, t) {
            t.reset();
          }),
            (this.areasXref = []),
            (this.options = null);
        },
        isSelectedOrStatic: function () {
          var e = this.effectiveOptions();
          return o.isBool(e.staticState) ? e.staticState : this.isSelected();
        },
        isSelected: function () {
          return o.isBool(this.selected)
            ? this.selected
            : o.isBool(this.owner.area_options.selected)
            ? this.owner.area_options.selected
            : !1;
        },
        isSelectable: function () {
          return o.isBool(this.effectiveOptions().staticState)
            ? !1
            : o.isBool(this.owner.options.staticState)
            ? !1
            : o.boolOrDefault(this.effectiveOptions().isSelectable, !0);
        },
        isDeselectable: function () {
          return o.isBool(this.effectiveOptions().staticState)
            ? !1
            : o.isBool(this.owner.options.staticState)
            ? !1
            : o.boolOrDefault(this.effectiveOptions().isDeselectable, !0);
        },
        isNotRendered: function () {
          var t = e(this.area);
          return (
            t.attr('nohref') ||
            !t.attr('href') ||
            this.effectiveOptions().isMask
          );
        },
        effectiveOptions: function (e) {
          var t = o.updateProps(
            {},
            this.owner.area_options,
            this.options,
            e || {},
            {
              id: this.areaId,
            }
          );
          return (t.selected = this.isSelected()), t;
        },
        effectiveRenderOptions: function (t, a) {
          var n,
            i = this.optsCache;
          return (
            (i && 'highlight' !== t) ||
              ((n = this.effectiveOptions(a)),
              (i = o.updateProps({}, n, n['render_' + t])),
              'highlight' !== t && (this.optsCache = i)),
            e.extend({}, i)
          );
        },
        changeState: function (t, a) {
          e.isFunction(this.owner.options.onStateChange) &&
            this.owner.options.onStateChange.call(this.owner.image, {
              key: this.key,
              state: t,
              selected: a,
            });
        },
        highlight: function (e) {
          var t = this.owner;
          this.effectiveOptions().highlight &&
            t.graphics.addShapeGroup(this, 'highlight', e),
            t.setHighlightId(this.areaId),
            this.changeState('highlight', !0);
        },
        drawSelection: function () {
          this.owner.graphics.addShapeGroup(this, 'select');
        },
      }),
      (i.MapArea = function (t, a, n) {
        if (t) {
          var i = this;
          (i.owner = t),
            (i.area = a),
            (i.areaDataXref = []),
            (i.originalCoords = []),
            e.each(o.split(a.coords), function (e, t) {
              i.originalCoords.push(parseFloat(t));
            }),
            (i.length = i.originalCoords.length),
            (i.shape = a.shape.toLowerCase()),
            (i.nohref = a.nohref || !a.href),
            i.configure(n);
        }
      }),
      (i.MapArea.prototype = {
        constructor: i.MapArea,
        configure: function (e) {
          this.keys = o.split(e);
        },
        reset: function () {
          this.area = null;
        },
        coords: function (t) {
          return e.map(this.originalCoords, function (e) {
            return t ? e : e + t;
          });
        },
      });
  })(jQuery),
  (function (e) {
    var t = e.mapster.utils;
    t.areaCorners = function (a, n, i, o, r) {
      var s,
        c,
        l,
        u,
        h,
        p,
        f,
        d,
        m,
        g,
        v,
        y,
        w,
        b,
        k,
        _,
        C,
        A,
        I,
        S,
        x = 0,
        T = 0,
        M = [];
      for (
        a = a.length ? a : [a],
          i = e(i ? i : document.body),
          s = i.offset(),
          k = s.left,
          _ = s.top,
          n && ((s = e(n).offset()), (x = s.left), (T = s.top)),
          b = 0;
        b < a.length;
        b++
      )
        if (((S = a[b]), 'AREA' === S.nodeName)) {
          switch (((C = t.split(S.coords, parseInt)), S.shape)) {
            case 'circle':
              for (
                v = C[0], y = C[1], A = C[2], M = [], b = 0;
                360 > b;
                b += 20
              )
                (I = (b * Math.PI) / 180),
                  M.push(v + A * Math.cos(I), y + A * Math.sin(I));
              break;
            case 'rect':
              M.push(C[0], C[1], C[2], C[1], C[2], C[3], C[0], C[3]);
              break;
            default:
              M = M.concat(C);
          }
          for (b = 0; b < M.length; b += 2)
            (M[b] = parseInt(M[b], 10) + x),
              (M[b + 1] = parseInt(M[b + 1], 10) + T);
        } else
          (S = e(S)),
            (s = S.position()),
            M.push(
              s.left,
              s.top,
              s.left + S.width(),
              s.top,
              s.left + S.width(),
              s.top + S.height(),
              s.left,
              s.top + S.height()
            );
      for (
        l = u = f = m = 999999, h = p = d = g = -1, b = M.length - 2;
        b >= 0;
        b -= 2
      )
        (v = M[b]),
          (y = M[b + 1]),
          l > v && ((l = v), (g = y)),
          v > h && ((h = v), (m = y)),
          u > y && ((u = y), (d = v)),
          y > p && ((p = y), (f = v));
      return (
        o &&
          r &&
          ((c = !1),
          e.each(
            [
              [d - o, u - r],
              [f, u - r],
              [l - o, g - r],
              [l - o, m],
              [h, g - r],
              [h, m],
              [d - o, p],
              [f, p],
            ],
            function (e, t) {
              return !c && t[0] > k && t[1] > _
                ? ((w = t), (c = !0), !1)
                : void 0;
            }
          ),
          c || (w = [h, p])),
        w
      );
    };
  })(jQuery),
  (function (e) {
    var t = e.mapster,
      a = t.utils,
      n = t.MapArea.prototype;
    (t.utils.getScaleInfo = function (e, t) {
      var a;
      return (
        t
          ? ((a = e.width / t.width || e.height / t.height),
            a > 0.98 && 1.02 > a && (a = 1))
          : ((a = 1), (t = e)),
        {
          scale: 1 !== a,
          scalePct: a,
          realWidth: t.width,
          realHeight: t.height,
          width: e.width,
          height: e.height,
          ratio: e.width / e.height,
        }
      );
    }),
      (t.utils.scaleMap = function (e, t, n) {
        var i = a.size(e),
          o = a.size(t, !0);
        if (!o.complete())
          throw 'Another script, such as an extension, appears to be interfering with image loading. Please let us know about this.';
        return i.complete() || (i = o), this.getScaleInfo(i, n ? o : null);
      }),
      (t.MapData.prototype.resize = function (n, i, o, r) {
        function s(a, n, i) {
          t.hasCanvas()
            ? ((a.width = n), (a.height = i))
            : (e(a).width(n), e(a).height(i));
        }

        function c() {
          (v.currentAction = ''),
            e.isFunction(r) && r(),
            v.processCommandQueue();
        }

        function l() {
          if ((s(v.overlay_canvas, n, i), m >= 0)) {
            var e = v.data[m];
            (e.tempOptions = {
              fade: !1,
            }),
              v.getDataForKey(e.key).highlight(),
              (e.tempOptions = null);
          }
          s(v.base_canvas, n, i), v.redrawSelections(), c();
        }

        function u() {
          e(v.image).css(f),
            (v.scaleInfo = a.getScaleInfo(
              {
                width: n,
                height: i,
              },
              {
                width: v.scaleInfo.realWidth,
                height: v.scaleInfo.realHeight,
              }
            )),
            e.each(v.data, function (t, a) {
              e.each(a.areas(), function (e, t) {
                t.resize();
              });
            });
        }
        var h,
          p,
          f,
          d,
          m,
          g,
          v = this;
        (r = r || o),
          (v.scaleInfo.width !== n || v.scaleInfo.height !== i) &&
            ((m = v.highlightId),
            n ||
              ((g = i / v.scaleInfo.realHeight),
              (n = Math.round(v.scaleInfo.realWidth * g))),
            i ||
              ((g = n / v.scaleInfo.realWidth),
              (i = Math.round(v.scaleInfo.realHeight * g))),
            (f = {
              width: String(n) + 'px',
              height: String(i) + 'px',
            }),
            t.hasCanvas() || e(v.base_canvas).children().remove(),
            (d = e(v.wrapper).find('.mapster_el').add(v.wrapper)),
            o
              ? ((p = []),
                (v.currentAction = 'resizing'),
                d.each(function (t, n) {
                  (h = a.defer()),
                    p.push(h),
                    e(n).animate(f, {
                      duration: o,
                      complete: h.resolve,
                      easing: 'linear',
                    });
                }),
                (h = a.defer()),
                p.push(h),
                a.when.all(p).then(l),
                u(),
                h.resolve())
              : (d.css(f), u(), l()));
      }),
      (t.MapArea = a.subclass(t.MapArea, function () {
        this.base.init(), this.owner.scaleInfo.scale && this.resize();
      })),
      (n.coords = function (e, t) {
        var a,
          n = [],
          i = e || this.owner.scaleInfo.scalePct,
          o = t || 0;
        if (1 === i && 0 === t) return this.originalCoords;
        for (a = 0; a < this.length; a++)
          n.push(Math.round(this.originalCoords[a] * i) + o);
        return n;
      }),
      (n.resize = function () {
        this.area.coords = this.coords().join(',');
      }),
      (n.reset = function () {
        this.area.coords = this.coords(1).join(',');
      }),
      (t.impl.resize = function (e, a, n, i) {
        if (!e && !a) return !1;
        var o = new t.Method(
          this,
          function () {
            this.resize(e, a, n, i);
          },
          null,
          {
            name: 'resize',
            args: arguments,
          }
        ).go();
        return o;
      });
  })(jQuery),
  (function (e) {
    function t(t, a, n) {
      var i;
      return (
        a
          ? ((i = 'string' == typeof a ? e(a) : e(a).clone()), i.append(t))
          : (i = e(t)),
        i
          .css(
            e.extend(n || {}, {
              display: 'block',
              position: 'absolute',
            })
          )
          .hide(),
        e('body').append(i),
        i.attr('data-opacity', i.css('opacity')).css('opacity', 0),
        i.show()
      );
    }

    function a(e, t) {
      var a = {
          left: t.left + 'px',
          top: t.top + 'px',
        },
        n = e.attr('data-opacity') || 0,
        i = e.css('z-index');
      (0 === parseInt(i, 10) || 'auto' === i) && (a['z-index'] = 9999),
        e.css(a).addClass('mapster_tooltip'),
        t.fadeDuration && t.fadeDuration > 0
          ? s.fader(e[0], 0, n, t.fadeDuration)
          : s.setOpacity(e[0], n);
    }

    function n(t, a, n, i, o, r) {
      var s = n + '.mapster-tooltip';
      return e.inArray(a, t) >= 0
        ? (i.unbind(s).bind(s, function (e) {
            (!o || o.call(this, e)) &&
              (i.unbind('.mapster-tooltip'), r && r.call(this));
          }),
          {
            object: i,
            event: s,
          })
        : void 0;
    }

    function i(e, t, n, i, o) {
      var r,
        c = {};
      return (
        (o = o || {}),
        t
          ? ((r = s.areaCorners(t, n, i, e.outerWidth(!0), e.outerHeight(!0))),
            (c.left = r[0]),
            (c.top = r[1]))
          : ((c.left = o.left), (c.top = o.top)),
        (c.left += o.offsetx || 0),
        (c.top += o.offsety || 0),
        (c.css = o.css),
        (c.fadeDuration = o.fadeDuration),
        a(e, c),
        e
      );
    }

    function o(e) {
      return e ? ('string' == typeof e || e.jquery ? e : e.content) : null;
    }
    var r = e.mapster,
      s = r.utils;
    e.extend(r.defaults, {
      toolTipContainer:
        '<div style="border: 2px solid black; background: #EEEEEE; width:160px; padding:4px; margin: 4px; -moz-box-shadow: 3px 3px 5px #535353; -webkit-box-shadow: 3px 3px 5px #535353; box-shadow: 3px 3px 5px #535353; -moz-border-radius: 6px 6px 6px 6px; -webkit-border-radius: 6px; border-radius: 6px 6px 6px 6px; opacity: 0.9;"></div>',
      showToolTip: !1,
      toolTipFade: !0,
      toolTipClose: ['area-mouseout', 'image-mouseout'],
      onShowToolTip: null,
      onHideToolTip: null,
    }),
      e.extend(r.area_defaults, {
        toolTip: null,
        toolTipClose: null,
      }),
      (r.MapData.prototype.clearToolTip = function () {
        this.activeToolTip &&
          (this.activeToolTip.stop().remove(),
          (this.activeToolTip = null),
          (this.activeToolTipID = null),
          s.ifFunction(this.options.onHideToolTip, this));
      }),
      (r.AreaData.prototype.showToolTip = function (a, o) {
        var r,
          c,
          l,
          u,
          h,
          p = {},
          f = this,
          d = f.owner,
          m = f.effectiveOptions();
        return (
          (o = o ? e.extend({}, o) : {}),
          (a = a || m.toolTip),
          (c =
            o.closeEvents ||
            m.toolTipClose ||
            d.options.toolTipClose ||
            'tooltip-click'),
          (h =
            'undefined' != typeof o.template
              ? o.template
              : d.options.toolTipContainer),
          (o.closeEvents = 'string' == typeof c ? (c = s.split(c)) : c),
          (o.fadeDuration =
            o.fadeDuration ||
            (d.options.toolTipFade
              ? d.options.fadeDuration || m.fadeDuration
              : 0)),
          (l = f.area
            ? f.area
            : e.map(f.areas(), function (e) {
                return e.area;
              })),
          d.activeToolTipID !== f.areaId
            ? (d.clearToolTip(),
              (d.activeToolTip = r = t(a, h, o.css)),
              (d.activeToolTipID = f.areaId),
              (u = function () {
                d.clearToolTip();
              }),
              n(c, 'area-click', 'click', e(d.map), null, u),
              n(c, 'tooltip-click', 'click', r, null, u),
              n(
                c,
                'image-mouseout',
                'mouseout',
                e(d.image),
                function (e) {
                  return (
                    e.relatedTarget &&
                    'AREA' !== e.relatedTarget.nodeName &&
                    e.relatedTarget !== f.area
                  );
                },
                u
              ),
              i(r, l, d.image, o.container, h, o),
              s.ifFunction(d.options.onShowToolTip, f.area, {
                toolTip: r,
                options: p,
                areaOptions: m,
                key: f.key,
                selected: f.isSelected(),
              }),
              r)
            : void 0
        );
      }),
      (r.impl.tooltip = function (a, s) {
        return new r.Method(
          this,
          function () {
            var r,
              c,
              l = this;
            if (a) {
              if (((c = e(a)), l.activeToolTipID === c[0])) return;
              l.clearToolTip(),
                (l.activeToolTip = r =
                  t(o(s), s.template || l.options.toolTipContainer, s.css)),
                (l.activeToolTipID = c[0]),
                n(
                  ['tooltip-click'],
                  'tooltip-click',
                  'click',
                  r,
                  null,
                  function () {
                    l.clearToolTip();
                  }
                ),
                (l.activeToolTip = r = i(r, c, l.image, s.container, s));
            } else l.clearToolTip();
          },
          function () {
            e.isPlainObject(a) && !s && (s = a), this.showToolTip(o(s), s);
          },
          {
            name: 'tooltip',
            args: arguments,
            key: a,
          }
        ).go();
      });
  })(jQuery);
